Exemple #1
0
    def test_move(self):
        self.update_events()
        self.cursor = self.get_latest_cursor()
        self.file.parent_id = self.test_subfolder.id
        self.file.save()
        events = self.get_most_recent_events(self.cursor)
        event_filter = {"metadata.id": self.file.id, "type": "move"}
        if self.account.service in LIMITED_EVENTS_SERVICES:
            event_filter["type"] = "add"
        event = self.filter_events(events, event_filter, expect_one=True)
        if event:
            self.assertEqual(event.metadata.id, self.file.id)
            if self.account.service in LIMITED_EVENTS_SERVICES:
                self.assertEqual(event.type, "add")
            else:
                self.assertEqual(event.type, "move")

    ###################
    # TODO: ENTERPRISE EVENTS
    # Need the Python SDK to support enterprise actions.
    ###################


def test_cases():
    return [utils.create_test_case(acc, Events) for acc in utils.accounts if acc.service in SUPPORTED_SERVICES]


if __name__ == "__main__":
    suite = utils.create_suite(test_cases())
    unittest.TextTestRunner(verbosity=2).run(suite)
        link = self.account.links.retrieve(id=self.link.id)
        driver = webdriver.Firefox()
        driver.get(link.url)
        driver.find_element_by_id('id_password').send_keys('testytest')
        driver.find_element_by_name('form-submit').click()
        self.assertTrue(
            'password entered is incorrect' not in driver.page_source)
        driver.close()

    def test_update_active_link(self):
        self.link.active = False
        self.link.save(file_id=self.test_file.id)
        r = requests.get(self.link.url)
        self.assertFalse(self.link.active)
        self.assertIn(r.status_code, [403, 404])

    def test_update_expired_link(self):
        self.link.expiration = datetime.datetime.utcnow().isoformat()
        self.link.save(file_id=self.test_file.id)
        r = requests.get(self.link.url)
        self.assertIn(r.status_code, [403, 404])


def test_cases():
    return [utils.create_test_case(acc, Link) for acc in utils.accounts]


if __name__ == '__main__':
    suite = utils.create_suite(test_cases())
    unittest.TextTestRunner(verbosity=2).run(suite)