Exemplo n.º 1
0
class TestUser(TestCase):
    @skipIf(not USERNAME or not PASSWORD, WARN)
    def test_returning_user_online(self):
        self.user = Ghost().bootstrap().init()
        self._assert_ok()

    def test_returning_user_offline(self):
        self.user = Ghost(offline=True).bootstrap().init()
        self._assert_ok()

    @skipIf(not USERNAME or not PASSWORD, WARN)
    def test_new_user_online(self):
        self.user = Ghost().init()
        self._assert_ok()

    def _assert_ok(self):
        self.assertIsInstance(self.user, User)
        self.assertTrue(all(list(map(isdir, self.user.folders))))
        self.assertIsInstance(self.user.engine, Engine)

    def tearDown(self):
        self.user.clear()
        self.user.logout()

    def test_new_user_offline(self):
        self.user = Ghost(offline=True, username='******', password='******')
        self.assertRaises(UserError, lambda: self.user.init())
Exemplo n.º 2
0
def test_archiver():
    user = Ghost(offline=True).bootstrap().flush().init()
    archive(user.db, OVERNIGHT_PROCESSED)

    assert len(user.db.query(Checkin).all()) == 2
    assert len(user.db.query(Checkpoint).all()) == 2
    assert user.db.query(Client.id).scalar() == 59017
    assert user.db.query(Order.id).scalar() == 1402120029

    user.clear()
Exemplo n.º 3
0
 def test_download_one_day(self):
     self.user = Ghost().bootstrap().flush().init()
     self._check()
Exemplo n.º 4
0
 def test_load_one_day_from_cache(self):
     self.user = Ghost(offline=True).bootstrap().init()
     self._check()
Exemplo n.º 5
0
 def test_new_user_offline(self):
     self.user = Ghost(offline=True, username='******', password='******')
     self.assertRaises(UserError, lambda: self.user.init())
Exemplo n.º 6
0
 def test_new_user_online(self):
     self.user = Ghost().init()
     self._assert_ok()
Exemplo n.º 7
0
 def test_returning_user_offline(self):
     self.user = Ghost(offline=True).bootstrap().init()
     self._assert_ok()