from unittest import TestCase

from sipa.model.user import BaseUser
from sipa.model.finance import BaseFinanceInformation


class TestBaseUserCase(TestCase):
    def test_BaseUser_is_abstract(self):
        with self.assertRaises(TypeError):
            BaseUser('')

    def test_BaseUser_has_flask_login_properties(self):
        assert BaseUser.is_authenticated
        assert BaseUser.is_active
        assert not BaseUser.is_anonymous

    # more can't be done here, we need some instances.


class DegenerateUser(BaseUser):
    address = None
    authenticate = None
    can_change_password = None
    change_password = None
    credit = None
    finance_information = None
    from_ip = None
    get = None
    has_connection = None
    hostalias = None
    hostname = None
    id = None
    login = None
    mac = None
    mail = None
    realname = None
    status = None
    traffic_history = None
    userdb = None
    userdb_status = None


class DegenerateUserTestCase(TestCase):
    User = DegenerateUser

    def test_instantiable(self):
        self.User(uid='')

    def test_finance_balance_unsupported(self):
        bal = self.User(uid='').finance_balance
        self.assertFalse(bal.supported)


class DegenerateFinanceInformation(BaseFinanceInformation):
    _balance = None
    has_to_pay = None
    history = None
    last_update = None


class UserWithFinancesTestCase(TestCase):
    class User(DegenerateUser):
        finance_information = DegenerateFinanceInformation()

    def setUp(self):
        self.bal = self.User(uid='').finance_balance

    def test_balance_row_supported(self):
        self.assertTrue(self.bal.supported)
        self.assertTrue(self.bal.empty)

    def test_balance_correct_name(self):
        self.assertEqual(self.bal.name, 'finance_balance')

@@ -259,16 +259,63 @@
 User('')
+  # pylint: disable=abstract-class-instantiated
 %0A%0A    de
@@ -364,39 +364,48 @@
 (self):%0A        
+self.
 assert
- 
+True(
 BaseUser.is_auth
@@ -413,16 +413,17 @@
 nticated
+)
 %0A       
@@ -423,23 +423,32 @@
         
+self.
 assert
- 
+True(
 BaseUser
@@ -457,16 +457,17 @@
 s_active
+)
 %0A       
@@ -471,19 +471,25 @@
     
+self.
 assert
- not 
+False(
 Base
@@ -505,16 +505,17 @@
 nonymous
+)
 %0A%0A    # 
@@ -1068,56 +1068,247 @@
     
-User = DegenerateUser%0A%0A    def test_instantiable
+def setUp(self):%0A        self.User = DegenerateUser%0A        self.uid = 'someone'%0A        self.user = self.User(uid=self.uid)%0A%0A    def test_uid_passed(self):%0A        self.assertEqual(self.user.uid, self.uid)%0A%0A    def test_get_id_implemented
 (sel
@@ -1328,117 +1328,326 @@
 elf.
-User(uid='')%0A%0A    def test_finance_balance_unsupported(self):%0A        bal = self.User(uid='').finance_balance
+assertEqual(self.user.get_id(), self.uid)%0A%0A    def test_equality_when_same_uid(self):%0A        self.assertEqual(self.user, self.User(uid=self.uid))%0A%0A    def test_inequality_when_other_uid(self):%0A        self.assertNotEqual(self.user, self.User(uid=self.uid + 'invalid'))%0A%0A    def test_finance_balance_unsupported(self):
 %0A   
@@ -1668,19 +1668,41 @@
 rtFalse(
-bal
+self.user.finance_balance
 .support

Add tests to and improve test_user