File indexing completed on 2024-05-12 05:04:11

0001 #!/usr/bin/env python3
0002 
0003 # SPDX-License-Identifier: BSD-3-Clause
0004 # SPDX-FileCopyrightText: 2023 Rishi Kumar <rsi.dev17@gmail.com>
0005 
0006 import sys
0007 import unittest
0008 from appium import webdriver
0009 from appium.options.common.base import AppiumOptions
0010 from appium.webdriver.common.appiumby import AppiumBy
0011 from appium.options.common.app_option import AppOption
0012 from selenium.webdriver.common.keys import Keys
0013 
0014 
0015 class ATSPIOptions(AppiumOptions, AppOption):
0016     pass
0017 
0018 
0019 class TimelineTest(unittest.TestCase):
0020 
0021     def setUp(self):
0022         options = ATSPIOptions()
0023         options.app = tokodon_offline_path
0024         self.driver = webdriver.Remote(
0025             command_executor='http://127.0.0.1:4723',
0026             options=options)
0027 
0028     def tearDown(self):
0029         self.driver.get_screenshot_as_file("failed_test_shot_{}.png".format(self.id()))
0030         self.driver.quit()
0031 
0032     def test_status_type(self):
0033         self.assertTrue(self.driver.find_element(by='description', value="Normal Status"))
0034         self.assertTrue(self.driver.find_element(by='description', value="Spoiler Status"))
0035 
0036     def test_favourite_interactions(self):
0037         favouriteButton=self.driver.find_element(by='description',value="Favourite")
0038         favouriteButton.click()
0039         self.assertTrue(self.driver.find_element(by='description', value="Favourited"))
0040 
0041     def test_bookmark_interactions(self):
0042         bookmarkButton=self.driver.find_element(by='description',value="Bookmark")
0043         bookmarkButton.click()
0044         self.assertTrue(self.driver.find_element(by='description', value="Bookmarked"))
0045 
0046     def test_boost_interactions(self):
0047         boostButton=self.driver.find_element(by='description',value="Boost")
0048         boostButton.click()
0049         self.assertTrue(self.driver.find_element(by='description', value="Boosted"))
0050 
0051     def test_status_media(self):
0052         searchElement = self.driver.find_element(by=AppiumBy.NAME, value="Home")
0053         searchElement.send_keys(Keys.DOWN)
0054         searchElement.send_keys(Keys.DOWN)
0055         searchElement.send_keys(Keys.DOWN)
0056         self.assertTrue(self.driver.find_element(by='description', value="Status with image attachment"))
0057         self.assertTrue(self.driver.find_element(by='description', value="Status with Video attachment"))
0058         self.assertTrue(self.driver.find_element(by='description', value="Status with GifV attachment"))
0059 
0060 
0061 if __name__ == '__main__':
0062     tokodon_offline_path = sys.argv[1]
0063     sys.argv.pop()
0064     unittest.main()