コード例 #1
0
 def test_get_address_with_relay_address_does_not_exist(
         self, logging_mocked, incr_mocked):
     try:
         _get_address(
             to_address=f'{self.local_portion}@{self.service_domain}',
             local_portion={self.local_portion},
             domain_portion=f'{self.service_domain}')
     except Exception as e:
         assert e.args[0] == 'RelayAddress matching query does not exist.'
         incr_mocked.assert_called_once_with('email_for_unknown_address', 1)
コード例 #2
0
 def test_get_address_with_relay_address_does_not_exist(
     self, logging_mocked, incr_mocked, domains_mocked
 ):
     domains_mocked.return_value = TEST_DOMAINS
     try:
         _get_address(
             to_address=f'{self.local_portion}@{self.service_domain}',
             local_portion={self.local_portion},
             domain_portion=f'{self.service_domain}'
         )
     except Exception as e:
         assert e.args[0] == 'Address does not exist'
         incr_mocked.assert_called_once_with('email_for_unknown_address', 1)
コード例 #3
0
    def test_get_address_with_deleted_relay_address(self, incr_mocked):
        hashed_address = address_hash(self.local_portion,
                                      domain=self.service_domain)
        baker.make(DeletedAddress, address_hash=hashed_address)

        try:
            _get_address(
                to_address=f'{self.local_portion}@{self.service_domain}',
                local_portion=self.local_portion,
                domain_portion=self.service_domain)
        except Exception as e:
            assert e.args[0] == 'RelayAddress matching query does not exist.'
            incr_mocked.assert_called_once_with('email_for_deleted_address', 1)
コード例 #4
0
    def test_get_address_with_deleted_relay_address(self, domains_mocked, incr_mocked):
        domains_mocked.return_value = TEST_DOMAINS
        hashed_address = address_hash(self.local_portion, domain=self.service_domain)
        baker.make(DeletedAddress, address_hash=hashed_address)

        try:
            _get_address(
                to_address=f'{self.local_portion}@{self.service_domain}',
                local_portion=self.local_portion,
                domain_portion=self.service_domain
            )
        except Exception as e:
            assert e.args[0] == 'Address does not exist'
            incr_mocked.assert_called_once_with('email_for_deleted_address', 1)
コード例 #5
0
    def test_get_address_with_relay_address(self):
        local_portion = 'foo'
        relay_address = baker.make(RelayAddress, address=local_portion)

        actual = _get_address(
            to_address=f'{self.local_portion}@{self.service_domain}',
            local_portion=f'{self.local_portion}',
            domain_portion=f'{self.service_domain}')
        assert actual == relay_address
コード例 #6
0
    def test_get_address_with_domain_address(self, _get_domain_address_mocked):
        expected = 'DomainAddress'
        _get_domain_address_mocked.return_value = expected
        # email_domain_mocked.return_value = service_domain

        actual = _get_address(
            to_address=f'{self.local_portion}@subdomain.{self.service_domain}',
            local_portion=self.local_portion,
            domain_portion=f'subdomain.{self.service_domain}')
        assert actual == expected
コード例 #7
0
    def test_get_address_with_relay_address(self, domains_mocked):
        domains_mocked.return_value = TEST_DOMAINS
        local_portion = 'foo'
        relay_address = baker.make(RelayAddress, address=local_portion)

        actual = _get_address(
            to_address=f'{self.local_portion}@{self.service_domain}',
            local_portion=f'{self.local_portion}',
            domain_portion=f'{self.service_domain}'
        )
        assert actual == relay_address