|
1 | 1 | import os |
2 | | -from mamba import description, it |
3 | | -from expects import expect, equal |
4 | 2 | from amadeus.mixins.encoder import encode_file_to_base64 |
5 | 3 | from amadeus.travel._encoder import from_file, from_base64 |
6 | 4 |
|
7 | | -with description('Mixins/Encoding'): |
8 | | - with it('file should be encoded to base64'): |
9 | | - file = str(os.path.dirname(os.path.abspath(__file__))) \ |
10 | | - + '/encoder_specs_file.eml' |
11 | | - base64 = 'Ym9va2luZw==' |
12 | | - expect(encode_file_to_base64(file)).to(equal(base64)) |
13 | 5 |
|
14 | | -with description('Travel/From File'): |
15 | | - with it('should generate the defined POST body from file'): |
16 | | - file = str(os.path.dirname(os.path.abspath(__file__))) \ |
17 | | - + '/encoder_specs_file.eml' |
18 | | - base64 = 'Ym9va2luZw==' |
19 | | - body = { |
20 | | - 'payload': base64, |
21 | | - } |
22 | | - expect(from_file(file)).to(equal(body)) |
| 6 | +def test_file_encoding(): |
| 7 | + file = str(os.path.dirname(os.path.abspath(__file__))) \ |
| 8 | + + '/encoder_specs_file.eml' |
| 9 | + base64 = 'Ym9va2luZw==' |
| 10 | + result = encode_file_to_base64(file) |
| 11 | + assert result == base64 |
23 | 12 |
|
24 | | -with description('Travel/From Base64'): |
25 | | - with it('should generate the defined POST body from base64'): |
26 | | - base64 = 'Ym9va2luZw==' |
27 | | - body = { |
28 | | - 'payload': base64, |
29 | | - } |
30 | | - expect(from_base64(base64)).to(equal(body)) |
| 13 | + |
| 14 | +def test_from_file(): |
| 15 | + file = str(os.path.dirname(os.path.abspath(__file__))) \ |
| 16 | + + '/encoder_specs_file.eml' |
| 17 | + base64 = 'Ym9va2luZw==' |
| 18 | + body = { |
| 19 | + 'payload': base64, |
| 20 | + } |
| 21 | + result = from_file(file) |
| 22 | + assert result == body |
| 23 | + |
| 24 | + |
| 25 | +def test_from_base64(): |
| 26 | + base64 = 'Ym9va2luZw==' |
| 27 | + body = { |
| 28 | + 'payload': base64, |
| 29 | + } |
| 30 | + result = from_base64(base64) |
| 31 | + assert result == body |
0 commit comments