File: import

package info (click to toggle)
xapers 0.9.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 644 kB
  • sloc: python: 2,571; sh: 1,294; makefile: 53
file content (75 lines) | stat: -rwxr-xr-x 2,647 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash

test_description='bibtex database importing.'

. ./test-lib.sh

################################################################

test_expect_code 1 'fail import without bibtex' \
    'xapers import'

sed "s|__DOC_DIR__|$DOC_DIR|g" <"$DOC_DIR"/all.bib >all.bib

# the following two tests provides entries so we can test that import
# updates existing entries

test_begin_subtest 'add initial documents'
xapers add --tags=foo --source="$DOC_DIR"/2.bib
xapers add --tags=bar --source="$DOC_DIR"/3.bib
xapers search '*' >OUTPUT
cat <<EOF >EXPECTED
id:1 [doi:10.9999/FOO.1] {Good_Bad_Up_Down_Left_Right_et_al._2012} (foo) "Multicolor cavity sadness"
id:2 [] {fake:1234} (bar) "When the liver meats the pavement"
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest 'import full bibtex with files'
xapers import --tags=new all.bib
xapers search '*' >OUTPUT
cat <<EOF >EXPECTED
id:5 [arxiv:1235] {arxiv:1235} (new) "Creation of the γ-verses"
id:1 [doi:10.9999/FOO.1] {Good_Bad_Up_Down_Left_Right_et_al._2012} (foo new) "Multicolor cavity sadness"
id:2 [] {fake:1234} (bar new) "When the liver meats the pavement"
id:4 [doi:10.9999/FOO.2] {30929234} (new) "The Circle and the Square: Forbidden Love"
id:3 [doi:10.9999/FOO.3] {30929} (new) "Circle are Squares"
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest 'search id:'
xapers search id:5 >OUTPUT
cat <<EOF >EXPECTED
id:5 [arxiv:1235] {arxiv:1235} (new) "Creation of the γ-verses"
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest 'search bib:'
xapers search key:30929234 >OUTPUT
cat <<EOF >EXPECTED
id:4 [doi:10.9999/FOO.2] {30929234} (new) "The Circle and the Square: Forbidden Love"
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest 'search text'
xapers search --output=summary lorem >OUTPUT
cat <<EOF >EXPECTED
id:2 [] {fake:1234} (bar new) "When the liver meats the pavement"
id:5 [arxiv:1235] {arxiv:1235} (new) "Creation of the γ-verses"
EOF
test_expect_equal_file OUTPUT EXPECTED

test_begin_subtest 're-import produces identical results'
xapers import --tags=new all.bib
xapers search '*' >OUTPUT
cat <<EOF >EXPECTED
id:5 [arxiv:1235] {arxiv:1235} (new) "Creation of the γ-verses"
id:1 [doi:10.9999/FOO.1] {Good_Bad_Up_Down_Left_Right_et_al._2012} (foo new) "Multicolor cavity sadness"
id:2 [] {fake:1234} (bar new) "When the liver meats the pavement"
id:4 [doi:10.9999/FOO.2] {30929234} (new) "The Circle and the Square: Forbidden Love"
id:3 [doi:10.9999/FOO.3] {30929} (new) "Circle are Squares"
EOF
test_expect_equal_file OUTPUT EXPECTED

################################################################

test_done