Exemple #1
0
 def test_get_user_transfers_should_not_return_other_user_transfer(self):
     transfer = Transfer(name="transfer from user",
                         amount=123,
                         date=datetime.date(2018, 11, 20),
                         from_user=self.other_user,
                         to_user=self.other_user)
     transfer.save()
     fetched_transfers = Transfer.get_user_transfers(
         2018, 11, self.fetching_user)
     self.assertListEqual([t.id for t in fetched_transfers], [])
Exemple #2
0
    def test_get_user_transfers_should_not_return_transfer_outside_year_requested(
            self):
        transfer_before = Transfer(name="transfer from user",
                                   amount=123,
                                   date=datetime.date(2017, 11, 20),
                                   from_user=self.fetching_user,
                                   to_user=self.fetching_user)
        transfer_before.save()

        transfer_after = Transfer(name="transfer from user",
                                  amount=123,
                                  date=datetime.date(2019, 11, 20),
                                  from_user=self.fetching_user,
                                  to_user=self.fetching_user)
        transfer_after.save()

        fetched_transfers = Transfer.get_user_transfers(
            2018, 11, self.fetching_user)
        self.assertListEqual([t.id for t in fetched_transfers], [])
Exemple #3
0
    def resolve_transfers(self, info, **kwargs):
        year = kwargs.get('year')
        month = kwargs.get('month')

        return Transfer.get_user_transfers(year, month, info.context.user)