Пример #1
0
 def validate_client(self, expiration):
     expiration_date = expiration.split('-')
     year = int(expiration_date[0])
     month = int(expiration_date[1])
     day = int(expiration_date[2])
     date_to_check = Date(year, month, day)
     current_date = Date.generate_current_date()
     if current_date > date_to_check:
         self.ui.Valid_InvalidLabel.setText('Client Invalid')
     else:
         self.ui.Valid_InvalidLabel.setText('Client Valid')
Пример #2
0
 def read_from_file(line):
     client = Client(line[0])
     client.id = line[1]
     creation_date = line[2].split('-')
     client.creation_date = Date(int(creation_date[0]),
                                 int(creation_date[1]),
                                 int(creation_date[2]))
     expiration_date = line[3].split('-')
     client.expiration_date = Date(int(expiration_date[0]),
                                   int(expiration_date[1]),
                                   int(expiration_date[2]))
     return client
Пример #3
0
 def test_str__valid_input__correct_creation_of_object(self):
     client = Client("Andrei Popa")
     self.assertTrue(client.name, "Andrei Popa")
     client.creation_date = Date(15, 4, 2020)
     self.assertTrue(str(client.creation_date), "15-04-2020")
     self.assertTrue(str(client.expiration_date), "15-07-2020")
     client.id = "1234"
     self.assertTrue(str(client.id), "1234")
Пример #4
0
 def test_remove_client__valid_input__correct_removal_of_object(self):
     current_date_string = str(Date.generate_current_date())
     repository = FileRepository("test.csv", Client.read_from_file, Client.write_to_file)
     service = Service(repository)
     service.add_client('Andrei Popa')
     service.add_client('Ilinca Irimia')
     service.remove_client('Andrei Popa', current_date_string)
     list_of_clients = service.repository
     self.assertEqual(len(list_of_clients), 1)
     f = open('test.csv', 'w')
     f.close()
Пример #5
0
    def __init__(self, name=""):
        self.__name = name
        self.__creation_date = Date.generate_current_date()
        self.__id = ""
        self.__expiration_date = Date(day=self.__creation_date.day)

        creation_date_copy = self.__creation_date
        if self.__creation_date.month <= 9:
            self.__expiration_date.year = self.__creation_date.year
            self.__expiration_date.month = self.__creation_date.month + 3
        else:
            self.__expiration_date.year = self.__creation_date.year + 1
            self.__expiration_date.month = (3 -
                                            (12 - self.__creation_date.month))
        self.__creation_date = creation_date_copy

        for c in self.__name:
            if 'A' <= c <= 'Z':
                self.__id = self.__id + c
        random_digit = random.randint(0, 99)
        self.__id += Date.id_string_version_of_output(
            self.__creation_date) + str(random_digit)
Пример #6
0
 def test_str__valid_input__correct_conversion_to_string(self):
     # Case 1
     date = Date(5, 6, 2000)
     self.assertTrue(date.__str__(), "05-06-2000")
     # Case 2
     date = Date(15, 6, 2000)
     self.assertTrue(date.__str__(), "15-06-2000")
     # Case 3
     date = Date(5, 11, 2000)
     self.assertTrue(date.__str__(), "05-11-2000")
     # Case 4
     date = Date(24, 11, 2000)
     self.assertTrue(date.__str__(), "24-11-2000")
Пример #7
0
 def test_generate_current_date__valid_input__current_date_returned_as_Date_object(
         self):
     date = Date.generate_current_date()
     date.day = 4
     self.assertEqual(date.day, 4)
Пример #8
0
 def test_string_to_date__valid_input__correct_conversion_to_date(self):
     date_string = "05-06-2000"
     date = Date.string_to_date(date_string)
     self.assertEqual(date.day, 5)
     self.assertEqual(date.month, 6)
     self.assertEqual(date.year, 2000)